		//存储数据
		function storageObj(id, obj) {
			//json.stringify可以将对象转换为 JSON 字符串
			var checkedIdStr = JSON.stringify(obj);
			//存储id和json字符串
			localStorage.setItem(id.toString(), checkedIdStr);
		};


		var userObj = {
			id: "user1",
			name: "giegie",
			bday: "1996-0-7-18",
			email: "12345@qq.com",
			tel: "18882022676",
			addr: [{province:'江西省',detial:'南昌市青山湖区江西财经大学静庐E栋',addrTel:'18882022676'}],
			password: "1234567",
			headUrl:"img/head/head1.jpg",
			friendList:["user1","user2","user3","user4"],
			productList:["product1"],
			balance:0
		}

		function filterUserLocal() {
			var userIDArray = new Array();
			//过滤
			for (var i = 0; i < localStorage.length; i++) {
				var key = localStorage.key(i); //获取本地存储的Key
				var filterStr = /^(user)[0-9]$/;
				//判断是否为用户数据
				if (filterStr.test(key)) {
					//判断key是否已经存在,inArray返回元素位置，没找到返回-1；
					if ($.inArray(key, userIDArray) != -1) {
						//console.log($.inArray(key, userIDArray));
						continue;
					} else {
						//采取压栈的方式
						userIDArray.push(key);
					}
				} else {
					continue;
				}
			}
			//json.stringify可以将对象转换为 JSON 字符串
			var userIDArrayStr = JSON.stringify(userIDArray);
			//将id数组存到localStorage,相当于建一个索引表
			localStorage.setItem("userIDArray", userIDArrayStr);
		}

		//获取用户索引表的长度
		function getUserArrayLen() {
			var userLen = 0;
			//判断是否有数据
			if (localStorage.getItem("userIDArray")) {

				//获取数组对象长度
				userIDArray = JSON.parse(localStorage.getItem("userIDArray"));
				userLen = userIDArray.length;
				console.log("lenth", userLen);
			}
			return userLen;
		}

		//创建用户ID
		function creatUserHUrl() {
			var headURL;
			var userLen = getUserArrayLen();
			//console.log("userLenth",userLen);
			//user1在id=1前加user目的是与其他数据做区分，便于过滤器过滤
			headURL= "/img/head/head" + userLen+".jpg";
			return headURL;
		}
		
		//创建用户ID
		function creatUserID() {
			var userID;
			var userLen = getUserArrayLen();
			//console.log("userLenth",userLen);
			//user1在id=1前加user目的是与其他数据做区分，便于过滤器过滤
			userID = "user" + userLen;
			return userID;
		}

		//设置用户列表
		function setUserContent(userObj) {
			userObj.id = creatUserID();
			userObj.name = $("#uname").val();
			userObj.bday = $("#bday").val();
			userObj.email = $("#email").val();
			userObj.tel = $("#tel").val();
			userObj.addr[0].province = $("#province").val();
			userObj.addr[0].detial = $("#aDetial").val();
			userObj.addr[0].addrTel =  $("#tel").val();
			userObj.password = $("#password").val();
			userObj.headUrl=creatUserHUrl();
			userObj.friendList=["user1","user2","user3","user4"];
			userObj.balance=50;//注册送50
			return userObj;
		}
		
		function modifiyUser(uobj){
			storageObj(uobj.id,uobj);
		}
		
		//获取登录用户
		function getUser(){
			let user = JSON.parse(localStorage.getItem(sessionStorage.getItem("LoginName")));
			return  user;
		}
		
		//修改密码
		function updatePassword(newPass){
			let user =getUser();
			user.password = newPass;
			modifiyUser(user);
			
		}
		
		//账户充值
		function updateBalance(money){
			let user =getUser();
			user.balance =parseFloat(user.balance)+parseFloat(money);
			modifiyUser(user);
		}
		
		//账户提现
		function declineBalance(money){
			let user =getUser();
			user.balance = parseFloat(user.balance)-parseFloat(money);
			modifiyUser(user);
		}
		
		//添加地址
		function addAddr(address){
			let user =getUser();
			user.addr.push(address);
			modifiyUser(user);
		}
		
		//添加地址
		function updateAddr(index, address){
			let user =getUser();
			user.addr[index]=address;
			modifiyUser(user);
		}
		
		//删除地址
		function deleteAddr(index){
			let user =getUser();
			user.addr.push(address);
			modifiyUser(user);
		}
		
		//发布商品后
		function addProduct(produID){
			let user =getUser();
			user.productList.push(produID);
			modifiyUser(user);
		}
